import { ElMessage, ElNotification } from 'element-plus'

const msg = (message: string, type: any) => {
  ElMessage({
    showClose: true,
    message,
    type,
    duration: 1500,
    grouping: true
  })
}

const Message = {
  success(str: string) {
    return msg(str, 'success')
  },
  info(str: string) {
    return msg(str, 'info')
  },
  warning(str: string) {
    return msg(str, 'warning')
  },
  error(str: string) {
    return msg(str, 'error')
  }
}
const notice = (str: string, type: any, title: string) => {
  ElNotification({
    showClose: true,
    type,
    duration: 1500,
    title,
    message: str
  })
}

const Notification = {
  success(str: string, title = 'Success') {
    return notice(str, 'success', title)
  },
  info(str: string, title = 'Info') {
    return notice(str, 'info', title)
  },
  warning(str: string, title = 'Warning') {
    return notice(str, 'warning', title)
  },
  error(str: string, title = 'Error') {
    return notice(str, 'error', title)
  }
}

export {
  Message,
  Notification
}
